package com.gee.spring.boot.influxdb.core.query.domain.lambda;

import com.gee.spring.boot.influxdb.core.util.ReflectionUtil;

import static com.gee.spring.boot.influxdb.core.constant.StrConstant.*;

/**
 * @author gepengjun
 * @since 2024/4/28 16:41
 */
public class ShadowLambdaMeta implements LambdaMeta {
    private final SerializedLambda lambda;

    public ShadowLambdaMeta(SerializedLambda lambda) {
        this.lambda = lambda;
    }

    @Override
    public String getImplMethodName() {
        return lambda.getImplMethodName();
    }

    @Override
    public Class<?> getInstantiatedClass() {
        String instantiatedMethodType = lambda.getInstantiatedMethodType();
        String instantiatedType = instantiatedMethodType.substring(2, instantiatedMethodType.indexOf(SEMICOLON)).replace(SLASH, DOT);
        return ReflectionUtil.toClassConfident(instantiatedType, lambda.getCapturingClass().getClassLoader());
    }
}